﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;

namespace Campus {
    class ExperimentalLaboratory : Structure {
        static public Texture2D BuildingTexture { get; private set; }
        static public Texture2D StaticTeamColorTexture { get; private set; }
        static public Texture2D ConstructionTexture { get; private set; }
        static public Vector2 StaticOrigin { get; private set; }
        static public List<Vector2> StaticTilesOccupied { get; private set; }
        static public void InitializeTextures(ContentManager Content) {
            BuildingTexture = Content.Load<Texture2D>("Structures/building_laboratory_base");
            StaticTeamColorTexture = Content.Load<Texture2D>("Structures/building_laboratory_team");
            ConstructionTexture = Content.Load<Texture2D>("Structures/building_laboratory_build");
            StaticOrigin = new Vector2(104, 206);

            StaticTilesOccupied = new List<Vector2>();
            StaticTilesOccupied.Add(new Vector2(0, 0));  // Tile this building is placed on.
            StaticTilesOccupied.Add(new Vector2(0, 1));
            StaticTilesOccupied.Add(new Vector2(0, 2));
            StaticTilesOccupied.Add(new Vector2(1, 0));
            StaticTilesOccupied.Add(new Vector2(1, 1));
            StaticTilesOccupied.Add(new Vector2(1, 2));
            StaticTilesOccupied.Add(new Vector2(2, 0));
            StaticTilesOccupied.Add(new Vector2(2, 1));
            StaticTilesOccupied.Add(new Vector2(2, 2));
        }
        private void CreateAbilities() {
            Abilities.Add("Build Robot", new BuildUnitAbility(MenuIcons.BuildRobotIcon, this, BuildRequirements.Units.Robot));
            Abilities.Add("Build DeLorean", new BuildUnitAbility(MenuIcons.BuildDeLoreanIcon, this, BuildRequirements.Units.DeLorean));
            Abilities.Add("Garrison", new GarrisonAbility(MenuIcons.GarrisonIcon, this, 100, delegate(Unit u) { return true; }));
            Abilities.Add("Expell Units", new ExpellUnitsAbility(MenuIcons.ExpellIcon, this));
        }
        public ExperimentalLaboratory(Player owner, Level level)
            : base(BuildingTexture, StaticTeamColorTexture, ConstructionTexture, StaticTilesOccupied, StaticOrigin, Vector2.Zero, 100, owner, level, new Dictionary<string,Ability>(), new Dictionary<string,AbilitySubMenu>())
        {
            m_name = "Experimental Laboratory";

            CreateAbilities();

            //TODO: Create abilities
        }

        public override string ToString()
        {
            string returnString = m_name + "\n" +
                                  "HP: " + m_currentHP + "/" + m_maxHP + "\nThis is your research gaining facility \nput up to 4 workers in here";
            return returnString;
        }
        public override void Update(Player player)
        {
            player.AddResearch(((GarrisonAbility)Abilities["Garrison"]).GarrisonedUnits.Count*4);
        }
    }
}
